<template>
  <div class="carpay-container">
    <div class="search-container">
    <span class="search-label">车牌号码：</span>

  <el-input v-model="searchs.carNumber" clearable placeholder="请输入车牌号码" class="search-main" />
  <span class="search-label">缴纳状态：</span>
<el-select v-model="searchs.cardStatus">
    <el-option
      v-for="item in cardStatusList"
      :key="item.id"
      :value="item.id"
      :label="item.name"
    />
  </el-select>

  <el-button type="primary" class="search-btn" @click="doSearch">查询</el-button>
    </div>
  
    <el-table :data="tableData" style="width: 100%">
      <el-table-column label="序号" width="180">
        <template slot-scope="scope">
          {{ params.pageSize*(params.page-1)+scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column prop="carNumber" label="车牌号码" width="180">
      </el-table-column>
      <el-table-column label="收费类型">
        <template slot-scope="scope">
        {{ scope.row.chargeType==='card'?'月卡':'临时停车' }}
      </template>
      </el-table-column>
      <el-table-column prop="parkingTime" label="停车总时长">
      </el-table-column>
      <el-table-column prop="actualCharge" label="缴纳费用（元）"> </el-table-column>
      <el-table-column label="缴纳状态"> 
        <template slot-scope="scope">
        {{ scope.row.paymentStatus===1?'已缴纳':'未缴纳' }}
      </template>
      </el-table-column>
      <el-table-column  label="缴纳方式">
         <template slot-scope="scope">
        {{ scope.row.paymentMethod==='Alipay'?'支付宝':'--' }}
      </template>
         </el-table-column>
      <el-table-column prop="paymentTime" label="缴纳时间"> </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="pageChange"
      :current-page="params.page"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="params.pageSize"
      layout="total,  prev, pager, next, sizes, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>
<script>
import { getCarPayList } from "@/api/carPay";
export default {
  data() {
    return {
      searchs:{
        carNumber: null,
        cardStatus: null
      },
      tableData: [],
      total: 0,
      params: {
        page: "1",
        pageSize: "10",
        carNumber:'',
        paymentStatus:''
      },
      cardStatusList:[
        {id: null,name: '全部'},
        {id: 0,name: '待缴纳'},
        {id: 1,name: '已缴纳'}]
    };
  },
  created() {
    this.render(this.params);
  },
  methods: {
    doSearch(){
      this.params.carNumber=this.searchs.carNumber
      this.params.paymentStatus=this.searchs.cardStatus
      this.render(this.params)
    },
    handleSizeChange(pageSize) {
      this.params.pageSize = pageSize;
      this.render(this.params);
    },
    pageChange(page) {
      this.params.page = page;
      this.render(this.params);
    },
    async render(params) {
      try {
        const { data } = await getCarPayList(params);
        this.total = data.total;
        this.tableData = data.rows;
      } catch (err) {
        console.log(err);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-button.el-button--primary{
  margin-bottom: 20px;
}
::v-deep .el-table__header-wrapper th{
  background-color:#f4f6f8
}
::v-deep .el-pagination{
  margin-top: 30px;
  text-align: right;
}

.search-container {
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgb(237, 237, 237, 0.9);
  padding-bottom: 20px;
  .search-main {
    width: 200px;
    margin-right: 10px;
  }
  .search-btn {
    margin-left: 20px;
    margin-top: 20px;
  }
}
</style>


